package com.my.hp_hr.dao.liuhao_dao;

import com.my.hp_hr.entity.liuhao_entity.Leave;
import com.my.hp_hr.util.BaseDAO;

import java.util.List;

public class LeaveDao extends BaseDAO {
    public void addEmployeeLeave(Leave leave) throws Exception {
        String sql="insert into lea values(null,?,?,?,?,?,?,?,null,?,null);";
        Object[]objects={leave.getEmployee_number(),leave.getDepartment_number(),leave.getStart_time(),leave.getEnd_time()
        ,leave.getDays(),leave.getReason(),leave.getType(),leave.getStatus()};
        addOrupdOrdel(sql,objects);
    }

    public int toGetTotal(int number) throws Exception {
        String sql="select count(0) from lea where employee_number=?;";
        Object[]objects={number};
        return getCount(sql,objects);
    }

    public List<Leave> pageLeaveList(int current, int pagesize,int number) throws Exception {
        String sql="select * from lea where employee_number=? limit ?,?;";
        Object[]objects={number,(current-1)*pagesize,pagesize};
        return getList(sql,new Leave(),objects);
    }
}
